
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <BTable>
#include <BXmlDocument>

#include <BImage>
#include <BLabel>
#include <BTextEdit>
#include <BScrollBar>
#include <BStatusBar>
#include <BProgressBar>
#include <BGridLayout>
#include <BStackLayout>
#include <BDockLayout>
#include <BFileDialog>
#include <BTabWidget>
#include <BScrollWidget>
#include <BMainWindow>

#include "PlayYardWidget.h"
#include "DesktopDialog.h"

class MainWindow : public BMainWindow
{
	BOBJECT(MainWindow)
public:
	MainWindow();
	~MainWindow();

	void loadSchool(const BString& fileName);
	void save();

protected:
	void slotAssetChanged(BWidget* sender, const BValue& value);

	void slotClassMateMoneyChanged(BObject* object, const BValue& value);
	void slotLabelClicked(BLabel* label);
	void slotLabelRightClicked(BLabel* label, const BValue& value);
	void slotMessageBoxRightClicked(BDialog* dialog);

	void slotLabelFramed(BLabel* labe);
	void slotButtonToggled(BButton* button, const BValue& value);
	void slotUpButtonClicked(BButton* button, const BValue& value);
	void slotDownButtonClicked();
	void slotTheButtonToggled(BObject* object, const BValue& value);

	void slotOpenButtonClicked(BObject* object, const BValue& value);
	void slotOpenGLActionTrigerred(BObject* object, const BValue& value);
	void slotPaintActionTriggered(BObject* object, const BValue& value);
	void slotTestActionTriggered(BObject* object, const BValue& value);
	void slotManageButtonClicked(BObject* object, const BValue& value);
	void slotLanguageTextChanged(BObject* object, const BValue& value);

	void slotRoomMenuStyled(BMenu* menu, const BValue& value);
	void slotInsertActionTriggered(BObject* object, const BValue& value);
	void slotRemoveActionTriggered(BObject* object, const BValue& value);
	void slotImportActionTriggered(BObject* object, const BValue& value);
	void slotExportActionTriggered(BObject* object, const BValue& value);
	void slotShowRoomActionChecked(BObject* object, const BValue& value);
	void slotSettingActionTriggered(BObject* object, const BValue& value);

	void slotProgressBarUpdated(BProgressBar* progressBar, const BValue& value);
	void slotTabClosing(BTabWidget* object, BValue& value);

	void slotWindowClose();

protected:
	virtual void closeEvent(const BEvent& event);
	virtual void adjustEvent(const BEvent& event);

	virtual void styleEvent(const BEvent& event);
	virtual void freshEvent(const BEvent& event);
	virtual void paintEvent(const BEvent& event);

	virtual void mouseMoveEvent(const BMouseEvent& mouseEvent);

	virtual void mouseClickEvent(const BMouseEvent& mouseEvent);
	virtual void mouseDoubleClickEvent(const BMouseEvent& mouseEvent);

private:
	BHolder<BMenu>		_roomMenu;
	BLineEdit*			_fileNameEdit;
	BButton*			_openButton;
	BButton*			_openglButton;
	BButton*			_manageButton;
	BComboBox*			_languageComboBox;
	PlayYardWidget*		_playYardWidget;
	BProgressBar*		_horizontalProgressBar;
	BScrollWidget*		_scrollWidget;
	BGridLayout*		_roomLayout;
	BStatusBar*			_statusBar;

	DesktopDialog*		_deskDialog;
	BFileDialog*		_fileDialog;

	BXmlNodeHolder		_configRoot;
	BHolder<ClassRoom>	_classRoom;
	BHolder<BLabel>		_selectedLabel;
	BImageHolder		_grassImage;
	BImageHolder		_captureImage;
	BTable<ClassMate*>	_classMateTable;
	BList<ClassMate*>	_classMateQueue;
	BList<ClassMate*>::iterator _hovered;
	BList<ClassMate*>::iterator _selected;
};

#endif
